$$.form = (function(){
	var 
	 select = /select-(one|multiple)/i
	,btns	= /file|undefined|reset|button/i
	,radio  = /radio|checkbox/i
	,submit = /submit/i;
	
	/**
	 * 修改按钮的样式。
	 */
	function addClassToBtn(cmp){
    	var btns = cmp.el.select('button');
    	btns.addCls('btnUp');
	}
	
	/**
	 * 设置焦点在用户输入框。
	 */
	function setFocus_onInput(cmp){
		var btn = this.el.down('input:first');
			btn.focus();
	}
	
	var defaultConfig_win = {
         title	: '默认表达' 
    	,width	: 495
        ,height	: 400
        ,layout	: 'fit'
    };
return {
	
	initHolder : function(cfg, containerType){
		cfg = cfg || {};
		
		for(var i in defaultConfig_win){
			if(!cfg[i]){
				cfg[i] = defaultConfig_win[i];
			}
		}
		
		var component = Ext.create(containerType || 'Ext.Window', cfg);
		component.on('afterrender', setFocus_onInput, component, {deplay : 1000});
	    return component;
	}
	
	,getRawHTMLbyTextarea: function(id){
		var 
		rawHtml = Ext.get(id);
		rawHtml = rawHtml.dom.innerHTML;
	    rawHtml = rawHtml.replace(/&amp;/g, "&").replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&quot;/g, '"');
		return rawHtml;
	}
	
	/**
	 * 该方法源自Ext.lib.Ajax.serializeForm(form)，原来返回字符，现改为返回JSON。
	 * @param {el} form
	 * @return {Objct}
	 */
	,serializeForm : function (form) {
		var 
		 fElements = form.elements || (document.forms[form] || Ext.getDom(form)).elements
		,hasSubmit = false
		,element
		,options
		,name
		,val
		,data = {}
		,type;

		Ext.each(fElements, function(element) {
			name = element.name;
			type = element.type;

			if (!element.disabled && name) {
				if (select.test(type)) {
					Ext.each(element.options, function(opt) {
						if (opt.selected) {
							data[encodeURIComponent(name)] = encodeURIComponent((opt.hasAttribute
									? opt.hasAttribute('value')
									: opt.getAttribute('value') !== null)
									? opt.value
									: opt.text);
						}
					});
				}else if(!btns.test(type)) {
					if (!(radio.test(type) && !element.checked) && !(type == 'submit' && hasSubmit)) {
						data[encodeURIComponent(name)] = encodeURIComponent(element.value);
						hasSubmit = submit.test(type);
					}
				}
			}
		});
		return data;
	}
};
})();